<? 
include_once("codelibrary/inc/variables.php");
include_once("session.php");
include_once("codelibrary/inc/functions.php");

$business_id = $_SESSION['business_id'];
$setup_id = $_REQUEST['id'];


$staff_limit = $_SESSION['staff_limit'];

if($staff_limit !=0) {
	$flag = checkStaffLimit($business_id,$staff_limit);
	if(!$flag) {
		$errormsg = "<br>You've reached the limit of staff memebers you can create. Please upgrade your package to add more staff members.<br>&nbsp;<br>&nbsp;";
	} else {
		$errormsg = "";
	}
}

if(isset($_REQUEST['Submit']))
{
	$fname = $_REQUEST['fname'];
	$lname = $_REQUEST['lname'];
	$sname = $_REQUEST['sname'];
	$email = $_REQUEST['email'];
	$username = $_REQUEST['username'];			
	$password = $_REQUEST['password'];
	$accesstype="staff";
	$staffmembertype='';
	$status=$GL_active;
	$loginip=$REMOTE_ADDR;
	
	if($IN_Access_Days!="")
	{
	   $accessdays=$IN_Access_Days;
	}
	else
	{
       $accessdays=0;
	}
	$dateadded=date("Y-m-d H:i:s");
	
	if($errormsg=="") {
	$query = "insert into staff(business_id,  first_name, last_name, screen_name, email, login, password,status) values('".$business_id."', '".$fname."', '".$lname."', '".$sname."', '".$email."', '".$username."', '".$password."',1)";
	}
	
	mysql_query($query) or die(mysql_error());	
	$staff_id=mysql_insert_id();
	
/*	if($username!='' && $password!='')
	{
		$insert_admin_sql="insert into $administrator_info_table set business_id='$business_id' , 
		staff_id='$staff_id' ,username='$username' , password='$password' , 
		accesstype='$accesstype' , staffmembertype='$staffmembertype' , status='$status' , 
		loginip='$loginip' , accessdays='$accessdays' , dateadded='$dateadded'";
		mysql_query($insert_admin_sql);
	}
	*/
	
	
	echo"<script>window.location.href='step5.php'</script>";
} 
if(isset($_REQUEST['Submit2']))
{
	$fname = $_REQUEST['fname'];
	$lname = $_REQUEST['lname'];
	$sname = $_REQUEST['sname'];
	$email = $_REQUEST['email'];
	$username = $_REQUEST['username'];			
	$password = $_REQUEST['password'];
	$accesstype="staff";
	$staffmembertype='';
	$status=$GL_active;
	$loginip=$REMOTE_ADDR;
	
	if($IN_Access_Days!="")
	{
	   $accessdays=$IN_Access_Days;
	}
	else
	{
       $accessdays=0;
	}
	$dateadded=date("Y-m-d H:i:s");
	
	$query = "insert into staff(business_id, first_name, last_name, screen_name, email, login, password,status) values('".$business_id."', '".$fname."', '".$lname."', '".$sname."', '".$email."', '".$username."', '".$password."',1)";
	
	mysql_query($query) or die(mysql_error());
	
	$staff_id=mysql_insert_id();
/*	
	if($username!='' && $password!='')
	{
		$insert_admin_sql="insert into $administrator_info_table set business_id='$business_id' , 
		staff_id='$staff_id' ,username='$username' , password='$password' , 
		accesstype='$accesstype' , staffmembertype='$staffmembertype' , status='$status' , 
		loginip='$loginip' , accessdays='$accessdays' , dateadded='$dateadded'";
		mysql_query($insert_admin_sql);
	}
	
	*/
	$_SESSION['setup_complete']=1;
	echo "<script>window.location.href='confirmation.php'</script>";
} 
if(isset($_REQUEST['Submit3']))
{
	echo"<script>window.location.href='confirmation.php'</script>";
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Online Appointment</title>

<base >
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<title>Staff Management</title>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">


<table cellpadding="0" cellspacing="0" border="0"><tr>
  <td style="background:url(images/top.gif) repeat-x top; ">
<table cellpadding="0" cellspacing="0" border="0" style="width:764px" align="center"> 
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" style="height:57">
				<tr>
					<td height="57">
<? html_header(); ?>					</td>
				</tr>
			</table>


		</td>
	</tr>
	<tr>
		<td>





<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="col_left">

<table border="0"cellspacing="0" cellpadding="0" class="box_width_left">
	<tr><td width="100%">
		<table border="0" cellspacing="0" cellpadding="0">
<tr><td>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="">
  <tr>
    <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0"  class="" height="91">
  <tr>
    <td align="center" height="91">
    <img border="0" src="images/logo.jpg" width="208" height="86"></td>
  </tr>
</table>
</td>
  </tr>
</table>
</td></tr>


          <tr>
            <td>
<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="box_header_txt" height="48">
  <tr>
    <td style="background-image: url(images/1_bg2-2.gif)" height="1">
      <p style="margin-top: 16">Setup Wizard </td>
  </tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0"   style="border-bottom:12px solid #ffffff;">
  <tr>
    <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0"  style="margin-bottom:0px;background:#7C7C7C url(images/1_line.gif) no-repeat left bottom;" >
  <tr>
    <td  style="padding:3px 16px 8px 25px;">
      <table width="108%" border="0">
        <tr>
          <td class="completesetup"> 1. Terms </td>
          </tr>
        <tr>
          <td class="completesetup">2. General Setting </td>
          </tr>
        <tr>
          <td class="completesetup">3. Hours of operations </td>
        </tr>
        <tr>
          <td height="13" class="completesetup">4. Services</td>
        </tr>
        <tr>
          <td class="leftmenutxt">5. Staff Members </td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
        <tr>
          <td class="leftmenutxt">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</td>
  </tr>
</table>
            </td>
          </tr>


          <tr>
            <td class="">&nbsp;
</td>
          </tr>

		</table>
	</td>
	<td><img src="images/spacer.gif" border="0" alt="" width="15" height="1"></td></tr>
</table>

    </td>

    <td width="100%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="cont_header_txt">
  <tr>
    <td>
			<table border="0" cellpadding="0" cellspacing="0" bgcolor="#EAEAEA" class="cont_header_txt">
				<tr>
					<td><img src="images/1_q1.gif" border="0" alt="" width="45" height="39"></td>
					<td style="width:100%">Step 5 - Staff members </td>
					<td><img src="images/1_q2.gif" border="0" alt="" width="10" height="39"></td>
				</tr>
			</table>										 
			</td>
  </tr>
</table>


						<table cellpadding="0" cellspacing="0" border="0" style="border:0px solid #DEDEDE; border-width:0px 1px 0px 1px;">
							<tr><td style="background:#ffffff;border:0px solid #ffffff; border-width:18px 5px 10px 5px;">
								  		
		
  
  <form name="frm" action="" method="post" >
  <table width="108%" border="1" cellpadding="3" cellspacing="2" class="table">
    <tr>
      <td height="27" colspan="3" valign="bottom" class="smallText"><?=$errormsg?></td>
      </tr>
    <tr>
      <td width="29%" height="27" valign="bottom" class="smallText">&nbsp;First Name </td>
      <td height="27" colspan="2" valign="top" nowrap class="smallText"><label></label>
        <label></label>        
        <label>
        <input name="fname" type="text" id="fname" size="30">
        </label></td>
      </tr>
    <? $dura = array("5 minutes", "10 minutes", "15 minutes", "20 minutes", "25 minutes", "30 minutes", "45 minutes", "50 minutes", "1 hrs", "1 hrs 5 minutes", "1 hrs 30 minutes", "1 hrs 45 minutes", "2 hrs");?>
    <tr>
      <td height="27" valign="bottom" class="smallText">&nbsp;Last Name </td>
      <td height="27" colspan="2" valign="bottom" class="smallText"><input name="lname" type="text" id="lname" size="30"></td>
      </tr>
    <tr>
      <td height="27" valign="bottom" class="smallText"> &nbsp;Screen Name </td>
      <td height="27" colspan="2" valign="bottom" nowrap class="smallText"><label>
        <input name="sname" type="text" id="sname" size="30">
      </label></td>
      </tr>
    
    <tr>
      <td height="30" valign="bottom" nowrap class="smallText">&nbsp;Email Address<br>
&nbsp;(If applicable) </td>
      <td height="27" colspan="2" valign="bottom" nowrap class="smallText"><input name="email" type="text" id="email" size="30"></td>
    </tr>
    <tr>
      <td height="30" valign="bottom" nowrap class="smallText">&nbsp;Login <br>
        &nbsp;(If applicable)</td>
      <td height="27" colspan="2" valign="bottom" nowrap class="smallText"><input name="username" type="text" id="username" size="30"></td>
    </tr>
    <tr>
      <td height="30" valign="bottom" nowrap class="smallText">&nbsp;Password <br>
        &nbsp;(If applicable)</td>
      <td height="27" colspan="2" valign="bottom" nowrap class="smallText"><label>
        <input name="password" type="text" id="password" size="30">
      </label></td>
      </tr>
    
    
    <tr>
      <td colspan="2" align="right" valign="middle" class="smallText">
       <input name="Submit" type="submit" class="button" value="Submit and Add Another">       </td>
	  <td width="48%" align="left" valign="middle" class="smallText">
            <input name="Submit2" type="submit" class="button" value="Submit and Continue">	  </td>
      <td width="48%" align="left" valign="middle" class="smallText">
            <input name="Submit3" type="submit" class="button" value="Continue"></td>
    </tr>
  </table>
  </form>
  
  <table border="0" cellspacing="0" cellpadding="0" align="center" class="box_width_cont product">
          <tr><td></td></tr>
        </table>
			</td></tr>

						</table>
						<table cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td><img src="images/1_q4.gif" border="0" alt="" width="10" height="10"></td>
								<td style="width:100%; background-image:url(images/1_li1.gif)"></td>
								<td><img src="images/1_q3.gif" border="0" alt="" width="10" height="10"></td>
							</tr>
						</table>
						


		
		
		</td>

    <td class="col_right">

<table border="0"cellspacing="0" cellpadding="0" class="box_width_right">
	<tr><td></td>
		<td width="100%">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr><td></td></tr>
			</table>
		</td>
	</tr>
</table>


    </td>
  </tr>
</table>



		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" style="height:98px; background-image:url(images/bot.gif)">
				<tr>
					<td>
						<table cellpadding="0" cellspacing="0" border="0" class="footer">
							<tr>									
								<td height="77"><img src="images/spacer.gif" border="0" alt="" width="25" height="1"></td>				
								<td style="width:207px"><br style="line-height:49px"><img src="images/p1.gif" border="0" alt="" width="145" height="24"><br></td>
							  <td style="width:532px">&nbsp;</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table></td></tr></table>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"></td>
  </tr>
</table>
</body>

</html>